<%@page import="java.util.ArrayList"%>
<%@page import="java.util.HashMap"%>
<%@page import="Filter.DAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%
    
    //String product_name=request.getParameter("product_name");
    //String namesql = "Select * from product where product_name="+product_name;
    String namesql = "Select * from product where product_name='Man'";
    ArrayList<HashMap> rslist = new DAO().query(namesql, new String[]{});
    HashMap map=rslist.get(0);
    session.setAttribute("map", map);
  
%>
<!DOCTYPE html>
<html>
    <head>
        <style>
        #Pic {
            width:100px;height:100px;position:absolute;
            background-color:yellow;left:50px;top:600px;
        }
        
        #tb{
            border-width:5px; width: 300px; 
        }
         </style>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
       
        <title>JSP Page</title>
    </head>
    <body>
        <div>
        <table id="tb" >
            <tr>
                <td> <img src="https://s.yimg.com/ja/ap/tw/peachwu/22276561_0224_140224_3c_Samsung-Grand2.jpg"></td>
                <td><h2>產品名稱 : <%=map.get("product_name") %></h2>
                    <h2>價格 : <%=map.get("product_price") %></h2> 
                    <form id="car">
                    <input type="button" value="加入購物車" onclick="car()" >
                      </form>
                </td>
              </tr>
          </table>
        </div>     
                    
        <iframe src="info2.jsp" width="400" height="400" name="say"></iframe>
   
        <script>
            function car(){
               document.getElementById("car").submit();
            <%
                    ArrayList list = new ArrayList();
                       if(session.getAttribute("carlist")!=null)
                     {     list=(ArrayList)session.getAttribute("carlist");
                           list.add(map);
                     }
                         session.setAttribute("carlist", list);
    
                %>
                        window.open( "carlist.jsp" , "您的購物車", "height=300,width=300,toolbar=0,scrollbars=1,status=0");
                }
        </script>
      
        
    </body>
</html>
